<?php
//dezend by http://www.yunlu99.com/ QQ:270656184
defined('BASEPATH') || exit('No direct script access allowed');
class Item_manage extends MY_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->verify_user();
	}

	public function index()
	{
		$stat = intval($this->input->get('stat'));

		if ($stat == 1) {
			$where = ' and status=0';
		}
		else if ($stat == 2) {
			$where = ' and status=1';
		}
		else if ($stat == 3) {
			$where = ' and status=2 and (begin<' . time() . ' and end>' . time() . ' and status<>3)';
		}
		else if ($stat == 4) {
			$where = ' and ((status=2 and deal>=target_amount and end<=' . time() . ') or status=3 or status=7)';
		}
		else if ($stat == 5) {
			$where = ' and status=2 and begin>' . time();
		}
		else if ($stat == 6) {
			$where = ' and status=2 and deal<target_amount and end<' . time();
		}
		else if ($stat == 7) {
			$where = ' and status=-1';
		}
		else {
			$where = '';
		}

		$d = $this->result_list(array('table' => 'items', 'where' => 'user_id=' . $this->user['id'] . $where, 'order' => 'add_time desc', 'url' => 'item_manage/index', 'per_page' => 10));

		foreach ($d['list'] as $k => $v) {
			$stat = get_stat($v);
			$d['list'][$k]['stat'] = $stat['name'];
		}

		$d['stat'] = $stat;
		$this->show(array('header', 'user_left', 'item_manage', 'footer'), $d);
	}
}

?>
